<template>
  <div class="main">
    <div v-if="dataList.length <= 0">
      <el-empty description="空空如也"></el-empty>
    </div>
    <div class="main_box" v-else>
      <div class="main_row swiper" id="banner4">
        <div class="swiper-wrapper">
          <div
            class="swiper-slide"
            v-for="(item, index) in dataList"
            :key="index"
          >
            <div
              class="item"
              v-for="(it, i) in item"
              :key="i"
              @click="linkToJobDetail(it.id)"
            >
              <div class="title">
                <span class="jobName">{{ it.jobName }}</span>
                <span class="salary"
                  >{{ it.lowestSalary }}-{{ it.highestSalary }}元/天</span
                >
              </div>
              <div class="txtRow">
                <span class="text">{{ it.workPeriod }}</span>
                <span class="lines"></span>
                <span class="text">{{ it.practicePeriod || 0 }}个月</span>
                <span class="lines" v-if="it.identify"></span>
                <span v-if="it.identify" class="text">{{
                  ["在校", "应届"][it.identify]
                }}</span>
                <span class="lines" v-if="it.education"></span>
                <span v-if="it.education" class="text">{{ it.education }}</span>
              </div>

              <div class="item_bot">
                <img :src="it.companyLogo" class="logo" />
                <span class="companyName">{{ it.companyName }}</span>
                <span class="city">{{ it.city }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="job_main_row">
        <div class="job-swiper-wrapper">
          <div  class="job-swiper-slide"
            v-for="(item, index) in dataList"
            :key="index"
          >
            <div
              class="item"
              v-for="(it, i) in item"
              :key="i"
              @click="linkToJobDetail(it.id)"
            >
              <div class="title">
                <span class="jobName">{{ it.jobName }}</span>
                <span class="salary"
                  >{{ it.lowestSalary }}-{{ it.highestSalary }}元/天</span
                >
              </div>
              <div class="txtRow">
                <span class="text">{{ it.workPeriod }}</span>
                <span class="lines"></span>
                <span class="text">{{ it.practicePeriod || 0 }}个月</span>
                <span class="lines" v-if="it.identify"></span>
                <span v-if="it.identify" class="text">{{
                  ["在校", "应届"][it.identify]
                }}</span>
                <span class="lines" v-if="it.education"></span>
                <span v-if="it.education" class="text">{{ it.education }}</span>
              </div>

              <div class="item_bot">
                <img :src="it.companyLogo" class="logo" />
                <span class="companyName">{{ it.companyName }}</span>
                <span class="city">{{ it.city }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.min.css";

export default {
  name: "item1",
  props: {
    dataList: Array,
  },
  components: {},
  data() {
    return {
      swiper: null,
    };
  },
  watch: {},
  methods: {
    linkToJobDetail(id) {
      this.$router.push({
        path: `/jobDetail/${id}`,
      });
    },
    slidePrev() {
      this.swiper.slidePrev();
    },
    slideNext() {
      this.swiper.slideNext();
    },
    initSwiper() {
      if (this.swiper === null) {
        this.swiper = new Swiper("#banner4", {
          observer: true,
          observeParents: true,
        });
      }
    },
  },
  created() {},
  mounted() {},
};
</script>
<style lang="less" scoped>
.main {
  width: 100%;
  overflow: hidden;
}
.main_box {
  width: 100%;
  position: relative;
  height: 440px;
  overflow-x: hidden;
  .job_main_row {
    display: none;
  }
    
  .main_row {
    width: 100%;
    padding: 30px 0 0;
    height: 440px;
    overflow: hidden;
    .swiper-slide {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      padding: 0 30px;
      height: 380px;
    }
    .item {
      width: calc((100% - 30px) / 3);
      height: 175px;
      background: #ffffff;
      border: 1px solid #ebebeb;
      box-shadow: 0px 0px 33px 2px rgba(124, 124, 124, 0.17);
      border-radius: 10px;
      margin-bottom: 20px;
      margin-right: 15px;
      transition-duration: 0.3s;
      padding: 22px 20px 78px;
      position: relative;
      font-family: MicrosoftYaHei;
      line-height: 20px;
      font-weight: 400;
      overflow: hidden;
      cursor: pointer;
      & > div {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .title {
        width: 100%;
        margin-bottom: 15px;
        display: flex;
        justify-content: space-between;
        .jobName {
          font-size: 19px;
          color: #000;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          max-width: 185px;
        }
        .salary {
          font-size: 18px;
          color: #fa606a;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          max-width: calc(100% - 185px);
        }
      }
      .txtRow {
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        line-height: 15px;
        margin-bottom: 23px;
        .lines {
          width: 1px;
          height: 15px;
          opacity: 0.7;
          border-left: 1px solid #9ca8be;
          margin: 0 10px;
        }
      }

      &:hover .jobName {
        color: #15389a;
      }
      .item_bot {
        width: 100%;
        position: relative;
        height: 78px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-top: 1px solid #ebebeb;
        font-size: 16px;
        font-family: MicrosoftYaHeiLight;
        font-weight: 400;
        color: #999999;
        line-height: 17px;
        padding-left: 70px;
        .companyName {
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          max-width: 185px;
        }
        .logo {
          position: absolute;
          width: 58px;
          height: 58px;
          border-radius: 50%;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
        }
      }
      &:nth-child(3),
      &:nth-child(6) {
        margin-right: 0;
      }
      &:hover {
        box-shadow: 0px 0px 25px 2px rgba(124, 124, 124, 0.41);
        // transform: scale(1.02);
      }
    }
  }
}

@media screen and (max-width: 480px) {
  .main_box {
    width: 100%;
    position: relative;
    height: auto;
    // overflow-x: hidden;
    // .job_main_row{
    //   display: inline-block;
    // }
    .main_row{
     
      width: 100%;
      padding: 30px 0 0;
      height: auto;
      overflow: hidden;
      .swiper-wrapper{
        display: none;
      }
    }
    .job_main_row{
      display: block;
      .job-swiper-wrapper {
        .job-swiper-slide {
          width: 100%;
          display: flex;
          flex-wrap: wrap;
          padding: 0 10px;
          // height: 380px;
          .item {
            width: 100%;
            height: 140px;
            background: #ffffff;
            border: 1px solid #ebebeb;
            // box-shadow: 0px 0px 33px 2px rgba(124, 124, 124, 0.17);
            box-shadow: none;
            border-radius: 10px;
            margin-bottom: 20px;
            margin-right: 0;
            transition-duration: 0.3s;
            padding: 15px 15px 0;
            position: relative;
            font-family: MicrosoftYaHei;
            line-height: 20px;
            font-weight: 400;
            overflow: hidden;
            cursor: pointer;
            & > div {
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
            }
            .title {
              width: 100%;
              margin-bottom: 15px;
              display: flex;
              justify-content: space-between;
              .jobName {
                font-size: 16px;
                color: #000;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                max-width: 185px;
              }
              .salary {
                font-size: 13px;
                color: #fa606a;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                max-width: calc(100% - 185px);
              }
            }
            .txtRow {
              font-size: 14px;
              font-weight: 400;
              color: #999999;
              line-height: 15px;
              margin-bottom: 14px;
              .lines {
                width: 1px;
                height: 15px;
                opacity: 0.7;
                border-left: 1px solid #9ca8be;
                margin: 0 10px;
              }
            }

            &:hover .jobName {
              color: #15389a;
            }
            .item_bot {
              width: 100%;
              position: relative;
              height: 55px;
              display: flex;
              align-items: center;
              justify-content: space-between;
              border-top: 1px solid #ebebeb;
              font-size: 14px;
              font-family: MicrosoftYaHeiLight;
              font-weight: 400;
              color: #999999;
              line-height: 17px;
              padding-left: 38px;
              .companyName {
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                max-width: 185px;
              }
              .logo {
                position: absolute;
                width: 30px;
                height: 30px;
                border-radius: 50%;
                left: 0;
                top: 50%;
                border: 1px solid #D4D6DA;
                transform: translateY(-50%);
              }
            }
            &:nth-child(3),
            &:nth-child(6) {
              margin-right: 0;
            }
            &:hover {
              // box-shadow: 0px 0px 25px 2px rgba(124, 124, 124, 0.41);
              box-shadow: none;
              // transform: scale(1.02);
            }
          }
        }
      }
    }
  }
}

</style>
